<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Usage example.</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gender.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.gender.html">Gender\Gender</a></div>
 <div class="up"><a href="gender.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="gender.example.admin" class="section">
  <h2 class="title">Usage example.</h2>
  <p class="para">
    Gender class usage example.
  </p>
  <div class="example" id="example-2405">
   <p><strong>Example #1 Usage example.</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">namespace&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$gender&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">;<br /><br />&nbsp;<br /></span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Milene"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$country&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">::</span><span style="color: #0000BB">FRANCE</span><span style="color: #007700">;<br />&nbsp;<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$gender</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$country</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$gender</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">country</span><span style="color: #007700">(</span><span style="color: #0000BB">$country</span><span style="color: #007700">);<br /><br />switch(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">::</span><span style="color: #0000BB">IS_FEMALE</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"The&nbsp;name&nbsp;%s&nbsp;is&nbsp;female&nbsp;in&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'country'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br /><br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">::</span><span style="color: #0000BB">IS_MOSTLY_FEMALE</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"The&nbsp;name&nbsp;%s&nbsp;is&nbsp;mostly&nbsp;female&nbsp;in&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'country'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br /><br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">::</span><span style="color: #0000BB">IS_MALE</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"The&nbsp;name&nbsp;%s&nbsp;is&nbsp;male&nbsp;in&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'country'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br /><br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">::</span><span style="color: #0000BB">IS_MOSTLY_MALE</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"The&nbsp;name&nbsp;%s&nbsp;is&nbsp;mostly&nbsp;male&nbsp;in&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'country'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br /><br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">::</span><span style="color: #0000BB">IS_UNISEX_NAME</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"The&nbsp;name&nbsp;%s&nbsp;is&nbsp;unisex&nbsp;in&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'country'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br /><br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">::</span><span style="color: #0000BB">IS_A_COUPLE</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"The&nbsp;name&nbsp;%s&nbsp;is&nbsp;both&nbsp;male&nbsp;and&nbsp;female&nbsp;in&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'country'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br /><br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">::</span><span style="color: #0000BB">NAME_NOT_FOUND</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"The&nbsp;name&nbsp;%s&nbsp;was&nbsp;not&nbsp;found&nbsp;for&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'country'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br /><br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">Gender</span><span style="color: #007700">::</span><span style="color: #0000BB">ERROR_IN_NAME</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"There&nbsp;is&nbsp;an&nbsp;error&nbsp;in&nbsp;the&nbsp;given&nbsp;name!\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;default:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"An&nbsp;error&nbsp;occurred!\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br /><br />}</span>
</span>
</code></div>
   </div>

  </div>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gender.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.gender.html">Gender\Gender</a></div>
 <div class="up"><a href="gender.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
